import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const store =new Vuex.Store({
    state: {
        userInfo: uni.getStorageSync('userInfo') || null,
        hasLogin: null
    },
    mutations: {
        setUserInfo(state, userInfo) {
            state.userInfo = userInfo
        },
        setHasLogin(state, hasLogin) {
            state.hasLogin = hasLogin
        }
    },
    actions: {
        setUserInfoAction({commit}, userInfo) {
            commit('setUserInfo', userInfo)
        },
        setHasLoginAction({commit}, hasLoginAction) {
            commit('setHasLogin', hasLoginAction)
        }
    }
})

export default store